<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<title>红包</title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<script src="__INDEX__/js/mui.min.js"></script>
	<link href="__INDEX__/css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="__INDEX__/css/iconfont.css" />
	<link rel="stylesheet" href="__INDEX__/css/style.css" />
	<link rel="stylesheet" href="__INDEX__/css/mall.css" />
	<link rel="stylesheet" href="__INDEX__/css/wallet.css" />
	<style type="text/css">
		.mui-bar-nav{background: #EFEFF4; box-shadow: none;}
		.mui-bar-nav a, .mui-bar-nav h1{color: #333333;}
	</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
	<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	<h1 class="mui-title">红包</h1>
</header>
<div class="mui-content">
	<div class="hongbbox">
		<div class="hbitembox">
			<div class="hongb_item">
				<div class="bt"><em>拼</em><span>总金额</span></div>
				<div class="hb_srk"><input id="hbmoney" type="text" placeholder="0.00" onkeyup="key_up(this)"></div>
				<div class="tip">元</div>
			</div>
			<div class="hbitem_tip">鼓励金余额：<em>{$info_user['score']}</em></div>
		</div>
		<div class="hbitembox">
			<div class="hongb_item">
				<div class="bt"><span>红包个数</span></div>
				<div class="hb_srk"><input id="hbnums" type="text" placeholder="填写个数" onkeyup="value=value.replace(/[^\d\.]/g,'')" onblur="value=value.replace(/[^\d\.]/g,'')"></div>
				<div class="tip">个</div>
			</div>
			<div class="hbitem_tip">当前为拼手气红包，
				<a href="hongb_put.html">改为普通红包</a>
			</div>
		</div>
		<div class="hb_tbtip"><textarea id="memo" placeholder="恭喜发财，大吉大利"></textarea></div>
		<div class="hb_pribox">
			<span>¥</span>
			<span class="hb_pri">0.00</span>
		</div>
		<a href="#" class="hb_btn">塞鼓励金进红包</a>
	</div>
</div>
<div class="mask" id='pay_by_score'>
	<div class="mask_con">
		<div class="top">
			<span class="del"><button type="button" onclick="$('.mask').hide()">X</button></span>
			<div style="text-align: center;">
				<span class="wz">请输入操作密码</span>
			</div>
			<span class="wz" style="width: 45%;"><a href="update_pwd2.html" style="float: right;font-size: 14px;color: red;margin-right: 15px;">忘记密码</a></span>
		</div>
		<div class="xfk_btn" id='is_pay_pwd' style="display: none;"><button type="button">设置支付密码</button></div>
		<div class="pwd-box" id='pay_pwd' style="none">
			<input type="tel" maxlength="6" class="pwd-input" id="pwd-input">
			<div class="fake-box">
				<input id="one" type="password" readonly="">
				<input type="password" readonly="">
				<input type="password" readonly="">
				<input type="password" readonly="">
				<input type="password" readonly="">
				<input type="password" readonly="">
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/jquery.min.js"></script>
<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
<script src="__PUBLIC__/static/layui/layui.all.js"></script>
<script src="__PUBLIC__/static/js/help.js"></script>

<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
	function hidex(){
		$('#pay_by_score').hide();
		$(".fake-box input").val("");
		$('#qrfuk_btn').attr('disabled', false);
	}
	function key_up(obj){
		clearNoNum1(obj);
		$(".hb_pri").text($(obj).val());
	}
	$(".hb_btn").click(function() {
		var hbmoney = $("#hbmoney").val();
		var hbnums = $("#hbnums").val();
		var my_score = parseFloat("{$info_user['score']}");
		var o = $(this);
		if(hbmoney == "") {
			layer.msg('请输入红包金额');
			return;
		}
		if(hbnums == "") {
			layer.msg('请输入红包个数');
			return;
		}
		if(hbmoney > 800) {
			layer.msg('个人红包不能超过800');
			return;
		}
		if(hbnums > 200) {
			layer.msg('红包个数不能超过200个');
			return;
		}
		if(hbmoney > my_score) {
			layer.msg('鼓励金账户余额不足');
			return;
		}
		$(this).attr({"disabled": "disabled"});
		$(".mask").show();
		$("#pwd-input").focus();
		$(".fake-box input").val();
	})
	var $input = $(".fake-box input");
	$("#pwd-input").on("input", function() {
		var pwd = $(this).val().trim();
		for(var i = 0, len = pwd.length; i < len; i++) {
			$input.eq("" + i + "").val(pwd[i]);
		}
		$input.each(function() {
			var index = $(this).index();
			if(index >= len) {
				$(this).val("");
			}
		});

		if(len == 6) {
		send_hb(pwd);
		}
	});

	function send_hb(pwd) {
		var hbmoney = $("#hbmoney").val();
		var hbnums = $("#hbnums").val();
		var index = layer.load(1, {shade: [0.1, '#fff']});
		$.ajax({
			url: "send_hb",
			data: {
				hbmoney: hbmoney,
				hbnums: hbnums,
				hbtype: 2,
				pwd:pwd,
				memo: $("#memo").val()
			},
			success: function(data) {
				layer.close(index);
				$(".mask").hide();
				$(".fake-box input").val("");
				if(data.code==200){
					window.location="hongb02.html?m="+data.id;
				}else{
					$("#pwd-input").val("");
					layer.msg(data.msg, {
							icon: 1,
							time: 1000
						}, function() {
							//location.reload();
						});
				}
			}
		})
	}
</script>